package com.southminority.ethnic.mapper.heritage;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.southminority.ethnic.pojo.HeritageResearchLink;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 非遗-研究成果关联Mapper
 * 
 * @author SouthMinority
 */
@Mapper
public interface HeritageResearchLinkMapper extends BaseMapper<HeritageResearchLink> {

    /**
     * 根据非遗项目ID查询相关研究成果
     * 
     * @param heritageId 非遗项目ID
     * @return 研究成果链接列表
     */
    @Select("SELECT * FROM heritage_research_link WHERE heritage_id = #{heritageId} AND status = 1 ORDER BY sort_order ASC, create_time DESC")
    List<HeritageResearchLink> selectByHeritageId(@Param("heritageId") Long heritageId);

    /**
     * 批量根据非遗项目ID列表查询研究成果
     * 
     * @param heritageIds 非遗项目ID列表
     * @return 研究成果链接列表
     */
    @Select("<script>" +
            "SELECT * FROM heritage_research_link " +
            "WHERE heritage_id IN " +
            "<foreach collection='heritageIds' item='id' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach> " +
            "AND status = 1 " +
            "ORDER BY heritage_id, sort_order ASC, create_time DESC" +
            "</script>")
    List<HeritageResearchLink> selectByHeritageIds(@Param("heritageIds") List<Long> heritageIds);
} 
